#pragma once
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr.h>

namespace Renderer
{
	class Graphics;

	class Texture
	{
	protected:
		Graphics* graphics;
		IDirect3DTexture9 * texture;
		ULONG width, height;
		D3DXVECTOR3 center;
	public:
		Texture();
		~Texture();

		IDirect3DTexture9* GetTextureCOM();


		bool Load(Graphics * graphics, char* fileName, DWORD transparent = 0, D3DFORMAT format = D3DFMT_UNKNOWN);

		bool Create(Graphics * graphics, DWORD width, DWORD height, D3DFORMAT format);
		bool Create(Graphics * graphics, IDirect3DTexture9* texture);

		bool Free();

		bool Loaded() const;

		long GetWidth() const;
		long GetHeight() const;

		D3DFORMAT GetFormat() const;

		bool Blit(long destX, long destY, long srcX = 0, long srcY = 0, long width = 0, long height = 0,
			float scaleX = 1.0f, float scaleY = 1.0f, float rotation = 0.0f, D3DCOLOR color = 0xFFFFFFFF);
	};

}
